<?php

/**
 * ListingsApi
 * PHP version 8.3.
 *
 * @category Class
 *
 * @author   OpenAPI Generator team
 *
 * @see     https://openapi-generator.tech
 */

/**
 * Selling Partner API for Listings Items.
 *
 * The Selling Partner API for Listings Items (Listings Items API) provides programmatic access to selling partner listings on Amazon. Use this API in collaboration with the Selling Partner API for Product Type Definitions, which you use to retrieve the information about Amazon product types needed to use the Listings Items API.  For more information, see the [Listings Items API Use Case Guide](https://developer-docs.amazon.com/sp-api/docs/listings-items-api-v2021-08-01-use-case-guide).
 *
 * The version of the OpenAPI document: 2021-08-01
 * Generated by: https://openapi-generator.tech
 * Generator version: 7.9.0
 */

/**
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

namespace SpApi\Api\listings\items\v2021_08_01;

use GuzzleHttp\Client;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\ConnectException;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Promise\PromiseInterface;
use GuzzleHttp\Psr7\MultipartStream;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\RequestOptions;
use SpApi\ApiException;
use SpApi\AuthAndAuth\RestrictedDataTokenSigner;
use SpApi\Configuration;
use SpApi\HeaderSelector;
use SpApi\Model\listings\items\v2021_08_01\Item;
use SpApi\Model\listings\items\v2021_08_01\ItemSearchResults;
use SpApi\Model\listings\items\v2021_08_01\ListingsItemPatchRequest;
use SpApi\Model\listings\items\v2021_08_01\ListingsItemPutRequest;
use SpApi\Model\listings\items\v2021_08_01\ListingsItemSubmissionResponse;
use SpApi\ObjectSerializer;
use Symfony\Component\RateLimiter\LimiterInterface;
use Symfony\Component\RateLimiter\RateLimiterFactory;
use Symfony\Component\RateLimiter\Storage\InMemoryStorage;

/**
 * ListingsApi Class Doc Comment.
 *
 * @category Class
 *
 * @author   OpenAPI Generator team
 *
 * @see     https://openapi-generator.tech
 */
class ListingsApi
{
    public ?LimiterInterface $deleteListingsItemRateLimiter;
    public ?LimiterInterface $getListingsItemRateLimiter;
    public ?LimiterInterface $patchListingsItemRateLimiter;
    public ?LimiterInterface $putListingsItemRateLimiter;
    public ?LimiterInterface $searchListingsItemsRateLimiter;
    protected ClientInterface $client;

    protected Configuration $config;

    protected HeaderSelector $headerSelector;

    /**
     * @var int Host index
     */
    protected int $hostIndex;

    private bool $rateLimiterEnabled;
    private InMemoryStorage $rateLimitStorage;

    /**
     * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec
     */
    public function __construct(
        Configuration $config,
        ?ClientInterface $client = null,
        ?bool $rateLimiterEnabled = true,
        ?HeaderSelector $selector = null,
        int $hostIndex = 0
    ) {
        $this->config = $config;
        $this->rateLimiterEnabled = $rateLimiterEnabled;

        if ($rateLimiterEnabled) {
            $this->rateLimitStorage = new InMemoryStorage();

            $factory = new RateLimiterFactory(Configuration::getRateLimitOptions('ListingsApi-deleteListingsItem'), $this->rateLimitStorage);
            $this->deleteListingsItemRateLimiter = $factory->create('ListingsApi-deleteListingsItem');
            $factory = new RateLimiterFactory(Configuration::getRateLimitOptions('ListingsApi-getListingsItem'), $this->rateLimitStorage);
            $this->getListingsItemRateLimiter = $factory->create('ListingsApi-getListingsItem');
            $factory = new RateLimiterFactory(Configuration::getRateLimitOptions('ListingsApi-patchListingsItem'), $this->rateLimitStorage);
            $this->patchListingsItemRateLimiter = $factory->create('ListingsApi-patchListingsItem');
            $factory = new RateLimiterFactory(Configuration::getRateLimitOptions('ListingsApi-putListingsItem'), $this->rateLimitStorage);
            $this->putListingsItemRateLimiter = $factory->create('ListingsApi-putListingsItem');
            $factory = new RateLimiterFactory(Configuration::getRateLimitOptions('ListingsApi-searchListingsItems'), $this->rateLimitStorage);
            $this->searchListingsItemsRateLimiter = $factory->create('ListingsApi-searchListingsItems');
        }

        $this->client = $client ?: new Client();
        $this->headerSelector = $selector ?: new HeaderSelector();
        $this->hostIndex = $hostIndex;
    }

    /**
     * Set the host index.
     *
     * @param int $hostIndex Host index (required)
     */
    public function setHostIndex(int $hostIndex): void
    {
        $this->hostIndex = $hostIndex;
    }

    /**
     * Get the host index.
     *
     * @return int Host index
     */
    public function getHostIndex(): int
    {
        return $this->hostIndex;
    }

    public function getConfig(): Configuration
    {
        return $this->config;
    }

    /**
     * Operation deleteListingsItem.
     *
     * @param string      $seller_id
     *                                         A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param string      $sku
     *                                         A selling partner provided identifier for an Amazon listing. (required)
     * @param string[]    $marketplace_ids
     *                                         A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param null|string $issue_locale
     *                                         A locale for localization of issues. When not provided, the default language code of the first marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     * @param null|string $restrictedDataToken Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function deleteListingsItem(
        string $seller_id,
        string $sku,
        array $marketplace_ids,
        ?string $issue_locale = null,
        ?string $restrictedDataToken = null
    ): ListingsItemSubmissionResponse {
        list($response) = $this->deleteListingsItemWithHttpInfo($seller_id, $sku, $marketplace_ids, $issue_locale, $restrictedDataToken);

        return $response;
    }

    /**
     * Operation deleteListingsItemWithHttpInfo.
     *
     * @param string      $seller_id
     *                                         A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param string      $sku
     *                                         A selling partner provided identifier for an Amazon listing. (required)
     * @param string[]    $marketplace_ids
     *                                         A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param null|string $issue_locale
     *                                         A locale for localization of issues. When not provided, the default language code of the first marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     * @param null|string $restrictedDataToken Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @return array of \SpApi\Model\listings\items\v2021_08_01\ListingsItemSubmissionResponse, HTTP status code, HTTP response headers (array of strings)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function deleteListingsItemWithHttpInfo(
        string $seller_id,
        string $sku,
        array $marketplace_ids,
        ?string $issue_locale = null,
        ?string $restrictedDataToken = null
    ): array {
        $request = $this->deleteListingsItemRequest($seller_id, $sku, $marketplace_ids, $issue_locale);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ListingsApi-deleteListingsItem');
        } else {
            $request = $this->config->sign($request);
        }

        try {
            $options = $this->createHttpClientOption();

            try {
                if ($this->rateLimiterEnabled) {
                    $this->deleteListingsItemRateLimiter->consume()->ensureAccepted();
                }
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getResponse()->getBody()}",
                    (int) $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? (string) $e->getResponse()->getBody() : null
                );
            } catch (ConnectException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    (int) $e->getCode(),
                    null,
                    null
                );
            }

            $statusCode = $response->getStatusCode();

            if ($statusCode < 200 || $statusCode > 299) {
                throw new ApiException(
                    sprintf(
                        '[%d] Error connecting to the API (%s)',
                        $statusCode,
                        (string) $request->getUri()
                    ),
                    $statusCode,
                    $response->getHeaders(),
                    (string) $response->getBody()
                );
            }
            if ('\SpApi\Model\listings\items\v2021_08_01\ListingsItemSubmissionResponse' === '\SplFileObject') {
                $content = $response->getBody(); // stream goes to serializer
            } else {
                $content = (string) $response->getBody();
                if ('\SpApi\Model\listings\items\v2021_08_01\ListingsItemSubmissionResponse' !== 'string') {
                    $content = json_decode($content);
                }
            }

            return [
                ObjectSerializer::deserialize($content, '\SpApi\Model\listings\items\v2021_08_01\ListingsItemSubmissionResponse', []),
                $response->getStatusCode(),
                $response->getHeaders(),
            ];
        } catch (ApiException $e) {
            $data = ObjectSerializer::deserialize(
                $e->getResponseBody(),
                '\SpApi\Model\listings\items\v2021_08_01\ErrorList',
                $e->getResponseHeaders()
            );
            $e->setResponseObject($data);

            throw $e;
        }
    }

    /**
     * Operation deleteListingsItemAsync.
     *
     * @param string      $seller_id
     *                                     A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param string      $sku
     *                                     A selling partner provided identifier for an Amazon listing. (required)
     * @param string[]    $marketplace_ids
     *                                     A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param null|string $issue_locale
     *                                     A locale for localization of issues. When not provided, the default language code of the first marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function deleteListingsItemAsync(
        string $seller_id,
        string $sku,
        array $marketplace_ids,
        ?string $issue_locale = null
    ): PromiseInterface {
        return $this->deleteListingsItemAsyncWithHttpInfo($seller_id, $sku, $marketplace_ids, $issue_locale)
            ->then(
                function ($response) {
                    return $response[0];
                }
            )
        ;
    }

    /**
     * Operation deleteListingsItemAsyncWithHttpInfo.
     *
     * @param string      $seller_id
     *                                     A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param string      $sku
     *                                     A selling partner provided identifier for an Amazon listing. (required)
     * @param string[]    $marketplace_ids
     *                                     A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param null|string $issue_locale
     *                                     A locale for localization of issues. When not provided, the default language code of the first marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function deleteListingsItemAsyncWithHttpInfo(
        string $seller_id,
        string $sku,
        array $marketplace_ids,
        ?string $issue_locale = null,
        ?string $restrictedDataToken = null
    ): PromiseInterface {
        $returnType = '\SpApi\Model\listings\items\v2021_08_01\ListingsItemSubmissionResponse';
        $request = $this->deleteListingsItemRequest($seller_id, $sku, $marketplace_ids, $issue_locale);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ListingsApi-deleteListingsItem');
        } else {
            $request = $this->config->sign($request);
        }
        if ($this->rateLimiterEnabled) {
            $this->deleteListingsItemRateLimiter->consume()->ensureAccepted();
        }

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    if ('\SplFileObject' === $returnType) {
                        $content = $response->getBody(); // stream goes to serializer
                    } else {
                        $content = (string) $response->getBody();
                        if ('string' !== $returnType) {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializer::deserialize($content, $returnType, []),
                        $response->getStatusCode(),
                        $response->getHeaders(),
                    ];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();

                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        (string) $response->getBody()
                    );
                }
            )
        ;
    }

    /**
     * Create request for operation 'deleteListingsItem'.
     *
     * @param string      $seller_id
     *                                     A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param string      $sku
     *                                     A selling partner provided identifier for an Amazon listing. (required)
     * @param string[]    $marketplace_ids
     *                                     A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param null|string $issue_locale
     *                                     A locale for localization of issues. When not provided, the default language code of the first marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function deleteListingsItemRequest(
        string $seller_id,
        string $sku,
        array $marketplace_ids,
        ?string $issue_locale = null
    ): Request {
        // verify the required parameter 'seller_id' is set
        if (null === $seller_id || (is_array($seller_id) && 0 === count($seller_id))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $seller_id when calling deleteListingsItem'
            );
        }
        // verify the required parameter 'sku' is set
        if (null === $sku || (is_array($sku) && 0 === count($sku))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $sku when calling deleteListingsItem'
            );
        }
        // verify the required parameter 'marketplace_ids' is set
        if (null === $marketplace_ids || (is_array($marketplace_ids) && 0 === count($marketplace_ids))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $marketplace_ids when calling deleteListingsItem'
            );
        }
        if (count($marketplace_ids) > 1) {
            throw new \InvalidArgumentException('invalid value for "$marketplace_ids" when calling ListingsApi.deleteListingsItem, number of items must be less than or equal to 1.');
        }

        $resourcePath = '/listings/2021-08-01/items/{sellerId}/{sku}';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $marketplace_ids,
            'marketplaceIds', // param base name
            'array', // openApiType
            'form', // style
            false, // explode
            true, // required
            $this->config
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $issue_locale,
            'issueLocale', // param base name
            'string', // openApiType
            '', // style
            false, // explode
            false, // required
            $this->config
        ) ?? []);

        // path params
        if (null !== $seller_id) {
            $resourcePath = str_replace(
                '{sellerId}',
                ObjectSerializer::toPathValue($seller_id),
                $resourcePath
            );
        }
        // path params
        if (null !== $sku) {
            $resourcePath = str_replace(
                '{sku}',
                ObjectSerializer::toPathValue($sku),
                $resourcePath
            );
        }

        $headers = $this->headerSelector->selectHeaders(
            ['application/json'],
            '',
            $multipart
        );

        // for model (json/xml)
        if (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
                    foreach ($formParamValueItems as $formParamValueItem) {
                        $multipartContents[] = [
                            'name' => $formParamName,
                            'contents' => $formParamValueItem,
                        ];
                    }
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);
            } elseif ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode($formParams);
            } else {
                // for HTTP post (form)
                $httpBody = ObjectSerializer::buildQuery($formParams, $this->config);
            }
        }

        $defaultHeaders = [];
        if ($this->config->getUserAgent()) {
            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
        }

        $headers = array_merge(
            $defaultHeaders,
            $headerParams,
            $headers
        );

        $query = ObjectSerializer::buildQuery($queryParams, $this->config);

        return new Request(
            'DELETE',
            $this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation getListingsItem.
     *
     * @param string        $seller_id
     *                                           A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param string        $sku
     *                                           A selling partner provided identifier for an Amazon listing. (required)
     * @param string[]      $marketplace_ids
     *                                           A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param null|string   $issue_locale
     *                                           A locale for localization of issues. When not provided, the default language code of the first marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     * @param null|string[] $included_data
     *                                           A comma-delimited list of data sets to include in the response. Default: &#x60;summaries&#x60;. (optional)
     * @param null|string   $restrictedDataToken Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function getListingsItem(
        string $seller_id,
        string $sku,
        array $marketplace_ids,
        ?string $issue_locale = null,
        ?array $included_data = null,
        ?string $restrictedDataToken = null
    ): Item {
        list($response) = $this->getListingsItemWithHttpInfo($seller_id, $sku, $marketplace_ids, $issue_locale, $included_data, $restrictedDataToken);

        return $response;
    }

    /**
     * Operation getListingsItemWithHttpInfo.
     *
     * @param string        $seller_id
     *                                           A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param string        $sku
     *                                           A selling partner provided identifier for an Amazon listing. (required)
     * @param string[]      $marketplace_ids
     *                                           A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param null|string   $issue_locale
     *                                           A locale for localization of issues. When not provided, the default language code of the first marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     * @param null|string[] $included_data
     *                                           A comma-delimited list of data sets to include in the response. Default: &#x60;summaries&#x60;. (optional)
     * @param null|string   $restrictedDataToken Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @return array of \SpApi\Model\listings\items\v2021_08_01\Item, HTTP status code, HTTP response headers (array of strings)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function getListingsItemWithHttpInfo(
        string $seller_id,
        string $sku,
        array $marketplace_ids,
        ?string $issue_locale = null,
        ?array $included_data = null,
        ?string $restrictedDataToken = null
    ): array {
        $request = $this->getListingsItemRequest($seller_id, $sku, $marketplace_ids, $issue_locale, $included_data);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ListingsApi-getListingsItem');
        } else {
            $request = $this->config->sign($request);
        }

        try {
            $options = $this->createHttpClientOption();

            try {
                if ($this->rateLimiterEnabled) {
                    $this->getListingsItemRateLimiter->consume()->ensureAccepted();
                }
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getResponse()->getBody()}",
                    (int) $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? (string) $e->getResponse()->getBody() : null
                );
            } catch (ConnectException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    (int) $e->getCode(),
                    null,
                    null
                );
            }

            $statusCode = $response->getStatusCode();

            if ($statusCode < 200 || $statusCode > 299) {
                throw new ApiException(
                    sprintf(
                        '[%d] Error connecting to the API (%s)',
                        $statusCode,
                        (string) $request->getUri()
                    ),
                    $statusCode,
                    $response->getHeaders(),
                    (string) $response->getBody()
                );
            }
            if ('\SpApi\Model\listings\items\v2021_08_01\Item' === '\SplFileObject') {
                $content = $response->getBody(); // stream goes to serializer
            } else {
                $content = (string) $response->getBody();
                if ('\SpApi\Model\listings\items\v2021_08_01\Item' !== 'string') {
                    $content = json_decode($content);
                }
            }

            return [
                ObjectSerializer::deserialize($content, '\SpApi\Model\listings\items\v2021_08_01\Item', []),
                $response->getStatusCode(),
                $response->getHeaders(),
            ];
        } catch (ApiException $e) {
            $data = ObjectSerializer::deserialize(
                $e->getResponseBody(),
                '\SpApi\Model\listings\items\v2021_08_01\ErrorList',
                $e->getResponseHeaders()
            );
            $e->setResponseObject($data);

            throw $e;
        }
    }

    /**
     * Operation getListingsItemAsync.
     *
     * @param string        $seller_id
     *                                       A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param string        $sku
     *                                       A selling partner provided identifier for an Amazon listing. (required)
     * @param string[]      $marketplace_ids
     *                                       A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param null|string   $issue_locale
     *                                       A locale for localization of issues. When not provided, the default language code of the first marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     * @param null|string[] $included_data
     *                                       A comma-delimited list of data sets to include in the response. Default: &#x60;summaries&#x60;. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function getListingsItemAsync(
        string $seller_id,
        string $sku,
        array $marketplace_ids,
        ?string $issue_locale = null,
        ?array $included_data = null
    ): PromiseInterface {
        return $this->getListingsItemAsyncWithHttpInfo($seller_id, $sku, $marketplace_ids, $issue_locale, $included_data)
            ->then(
                function ($response) {
                    return $response[0];
                }
            )
        ;
    }

    /**
     * Operation getListingsItemAsyncWithHttpInfo.
     *
     * @param string        $seller_id
     *                                       A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param string        $sku
     *                                       A selling partner provided identifier for an Amazon listing. (required)
     * @param string[]      $marketplace_ids
     *                                       A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param null|string   $issue_locale
     *                                       A locale for localization of issues. When not provided, the default language code of the first marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     * @param null|string[] $included_data
     *                                       A comma-delimited list of data sets to include in the response. Default: &#x60;summaries&#x60;. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function getListingsItemAsyncWithHttpInfo(
        string $seller_id,
        string $sku,
        array $marketplace_ids,
        ?string $issue_locale = null,
        ?array $included_data = null,
        ?string $restrictedDataToken = null
    ): PromiseInterface {
        $returnType = '\SpApi\Model\listings\items\v2021_08_01\Item';
        $request = $this->getListingsItemRequest($seller_id, $sku, $marketplace_ids, $issue_locale, $included_data);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ListingsApi-getListingsItem');
        } else {
            $request = $this->config->sign($request);
        }
        if ($this->rateLimiterEnabled) {
            $this->getListingsItemRateLimiter->consume()->ensureAccepted();
        }

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    if ('\SplFileObject' === $returnType) {
                        $content = $response->getBody(); // stream goes to serializer
                    } else {
                        $content = (string) $response->getBody();
                        if ('string' !== $returnType) {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializer::deserialize($content, $returnType, []),
                        $response->getStatusCode(),
                        $response->getHeaders(),
                    ];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();

                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        (string) $response->getBody()
                    );
                }
            )
        ;
    }

    /**
     * Create request for operation 'getListingsItem'.
     *
     * @param string        $seller_id
     *                                       A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param string        $sku
     *                                       A selling partner provided identifier for an Amazon listing. (required)
     * @param string[]      $marketplace_ids
     *                                       A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param null|string   $issue_locale
     *                                       A locale for localization of issues. When not provided, the default language code of the first marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     * @param null|string[] $included_data
     *                                       A comma-delimited list of data sets to include in the response. Default: &#x60;summaries&#x60;. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function getListingsItemRequest(
        string $seller_id,
        string $sku,
        array $marketplace_ids,
        ?string $issue_locale = null,
        ?array $included_data = null
    ): Request {
        // verify the required parameter 'seller_id' is set
        if (null === $seller_id || (is_array($seller_id) && 0 === count($seller_id))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $seller_id when calling getListingsItem'
            );
        }
        // verify the required parameter 'sku' is set
        if (null === $sku || (is_array($sku) && 0 === count($sku))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $sku when calling getListingsItem'
            );
        }
        // verify the required parameter 'marketplace_ids' is set
        if (null === $marketplace_ids || (is_array($marketplace_ids) && 0 === count($marketplace_ids))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $marketplace_ids when calling getListingsItem'
            );
        }
        if (count($marketplace_ids) > 1) {
            throw new \InvalidArgumentException('invalid value for "$marketplace_ids" when calling ListingsApi.getListingsItem, number of items must be less than or equal to 1.');
        }

        $resourcePath = '/listings/2021-08-01/items/{sellerId}/{sku}';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $marketplace_ids,
            'marketplaceIds', // param base name
            'array', // openApiType
            'form', // style
            false, // explode
            true, // required
            $this->config
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $issue_locale,
            'issueLocale', // param base name
            'string', // openApiType
            '', // style
            false, // explode
            false, // required
            $this->config
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $included_data,
            'includedData', // param base name
            'array', // openApiType
            'form', // style
            false, // explode
            false, // required
            $this->config
        ) ?? []);

        // path params
        if (null !== $seller_id) {
            $resourcePath = str_replace(
                '{sellerId}',
                ObjectSerializer::toPathValue($seller_id),
                $resourcePath
            );
        }
        // path params
        if (null !== $sku) {
            $resourcePath = str_replace(
                '{sku}',
                ObjectSerializer::toPathValue($sku),
                $resourcePath
            );
        }

        $headers = $this->headerSelector->selectHeaders(
            ['application/json'],
            '',
            $multipart
        );

        // for model (json/xml)
        if (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
                    foreach ($formParamValueItems as $formParamValueItem) {
                        $multipartContents[] = [
                            'name' => $formParamName,
                            'contents' => $formParamValueItem,
                        ];
                    }
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);
            } elseif ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode($formParams);
            } else {
                // for HTTP post (form)
                $httpBody = ObjectSerializer::buildQuery($formParams, $this->config);
            }
        }

        $defaultHeaders = [];
        if ($this->config->getUserAgent()) {
            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
        }

        $headers = array_merge(
            $defaultHeaders,
            $headerParams,
            $headers
        );

        $query = ObjectSerializer::buildQuery($queryParams, $this->config);

        return new Request(
            'GET',
            $this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation patchListingsItem.
     *
     * @param string                   $seller_id
     *                                                      A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param string                   $sku
     *                                                      A selling partner provided identifier for an Amazon listing. (required)
     * @param string[]                 $marketplace_ids
     *                                                      A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param ListingsItemPatchRequest $body
     *                                                      The request body schema for the &#x60;patchListingsItem&#x60; operation. (required)
     * @param null|string[]            $included_data
     *                                                      A comma-delimited list of data sets to include in the response. Default: &#x60;issues&#x60;. (optional)
     * @param null|string              $mode
     *                                                      The mode of operation for the request. (optional)
     * @param null|string              $issue_locale
     *                                                      A locale for localization of issues. When not provided, the default language code of the first marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     * @param null|string              $restrictedDataToken Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function patchListingsItem(
        string $seller_id,
        string $sku,
        array $marketplace_ids,
        ListingsItemPatchRequest $body,
        ?array $included_data = null,
        ?string $mode = null,
        ?string $issue_locale = null,
        ?string $restrictedDataToken = null
    ): ListingsItemSubmissionResponse {
        list($response) = $this->patchListingsItemWithHttpInfo($seller_id, $sku, $marketplace_ids, $body, $included_data, $mode, $issue_locale, $restrictedDataToken);

        return $response;
    }

    /**
     * Operation patchListingsItemWithHttpInfo.
     *
     * @param string                   $seller_id
     *                                                      A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param string                   $sku
     *                                                      A selling partner provided identifier for an Amazon listing. (required)
     * @param string[]                 $marketplace_ids
     *                                                      A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param ListingsItemPatchRequest $body
     *                                                      The request body schema for the &#x60;patchListingsItem&#x60; operation. (required)
     * @param null|string[]            $included_data
     *                                                      A comma-delimited list of data sets to include in the response. Default: &#x60;issues&#x60;. (optional)
     * @param null|string              $mode
     *                                                      The mode of operation for the request. (optional)
     * @param null|string              $issue_locale
     *                                                      A locale for localization of issues. When not provided, the default language code of the first marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     * @param null|string              $restrictedDataToken Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @return array of \SpApi\Model\listings\items\v2021_08_01\ListingsItemSubmissionResponse, HTTP status code, HTTP response headers (array of strings)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function patchListingsItemWithHttpInfo(
        string $seller_id,
        string $sku,
        array $marketplace_ids,
        ListingsItemPatchRequest $body,
        ?array $included_data = null,
        ?string $mode = null,
        ?string $issue_locale = null,
        ?string $restrictedDataToken = null
    ): array {
        $request = $this->patchListingsItemRequest($seller_id, $sku, $marketplace_ids, $body, $included_data, $mode, $issue_locale);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ListingsApi-patchListingsItem');
        } else {
            $request = $this->config->sign($request);
        }

        try {
            $options = $this->createHttpClientOption();

            try {
                if ($this->rateLimiterEnabled) {
                    $this->patchListingsItemRateLimiter->consume()->ensureAccepted();
                }
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getResponse()->getBody()}",
                    (int) $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? (string) $e->getResponse()->getBody() : null
                );
            } catch (ConnectException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    (int) $e->getCode(),
                    null,
                    null
                );
            }

            $statusCode = $response->getStatusCode();

            if ($statusCode < 200 || $statusCode > 299) {
                throw new ApiException(
                    sprintf(
                        '[%d] Error connecting to the API (%s)',
                        $statusCode,
                        (string) $request->getUri()
                    ),
                    $statusCode,
                    $response->getHeaders(),
                    (string) $response->getBody()
                );
            }
            if ('\SpApi\Model\listings\items\v2021_08_01\ListingsItemSubmissionResponse' === '\SplFileObject') {
                $content = $response->getBody(); // stream goes to serializer
            } else {
                $content = (string) $response->getBody();
                if ('\SpApi\Model\listings\items\v2021_08_01\ListingsItemSubmissionResponse' !== 'string') {
                    $content = json_decode($content);
                }
            }

            return [
                ObjectSerializer::deserialize($content, '\SpApi\Model\listings\items\v2021_08_01\ListingsItemSubmissionResponse', []),
                $response->getStatusCode(),
                $response->getHeaders(),
            ];
        } catch (ApiException $e) {
            $data = ObjectSerializer::deserialize(
                $e->getResponseBody(),
                '\SpApi\Model\listings\items\v2021_08_01\ErrorList',
                $e->getResponseHeaders()
            );
            $e->setResponseObject($data);

            throw $e;
        }
    }

    /**
     * Operation patchListingsItemAsync.
     *
     * @param string                   $seller_id
     *                                                  A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param string                   $sku
     *                                                  A selling partner provided identifier for an Amazon listing. (required)
     * @param string[]                 $marketplace_ids
     *                                                  A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param ListingsItemPatchRequest $body
     *                                                  The request body schema for the &#x60;patchListingsItem&#x60; operation. (required)
     * @param null|string[]            $included_data
     *                                                  A comma-delimited list of data sets to include in the response. Default: &#x60;issues&#x60;. (optional)
     * @param null|string              $mode
     *                                                  The mode of operation for the request. (optional)
     * @param null|string              $issue_locale
     *                                                  A locale for localization of issues. When not provided, the default language code of the first marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function patchListingsItemAsync(
        string $seller_id,
        string $sku,
        array $marketplace_ids,
        ListingsItemPatchRequest $body,
        ?array $included_data = null,
        ?string $mode = null,
        ?string $issue_locale = null
    ): PromiseInterface {
        return $this->patchListingsItemAsyncWithHttpInfo($seller_id, $sku, $marketplace_ids, $body, $included_data, $mode, $issue_locale)
            ->then(
                function ($response) {
                    return $response[0];
                }
            )
        ;
    }

    /**
     * Operation patchListingsItemAsyncWithHttpInfo.
     *
     * @param string                   $seller_id
     *                                                  A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param string                   $sku
     *                                                  A selling partner provided identifier for an Amazon listing. (required)
     * @param string[]                 $marketplace_ids
     *                                                  A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param ListingsItemPatchRequest $body
     *                                                  The request body schema for the &#x60;patchListingsItem&#x60; operation. (required)
     * @param null|string[]            $included_data
     *                                                  A comma-delimited list of data sets to include in the response. Default: &#x60;issues&#x60;. (optional)
     * @param null|string              $mode
     *                                                  The mode of operation for the request. (optional)
     * @param null|string              $issue_locale
     *                                                  A locale for localization of issues. When not provided, the default language code of the first marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function patchListingsItemAsyncWithHttpInfo(
        string $seller_id,
        string $sku,
        array $marketplace_ids,
        ListingsItemPatchRequest $body,
        ?array $included_data = null,
        ?string $mode = null,
        ?string $issue_locale = null,
        ?string $restrictedDataToken = null
    ): PromiseInterface {
        $returnType = '\SpApi\Model\listings\items\v2021_08_01\ListingsItemSubmissionResponse';
        $request = $this->patchListingsItemRequest($seller_id, $sku, $marketplace_ids, $body, $included_data, $mode, $issue_locale);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ListingsApi-patchListingsItem');
        } else {
            $request = $this->config->sign($request);
        }
        if ($this->rateLimiterEnabled) {
            $this->patchListingsItemRateLimiter->consume()->ensureAccepted();
        }

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    if ('\SplFileObject' === $returnType) {
                        $content = $response->getBody(); // stream goes to serializer
                    } else {
                        $content = (string) $response->getBody();
                        if ('string' !== $returnType) {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializer::deserialize($content, $returnType, []),
                        $response->getStatusCode(),
                        $response->getHeaders(),
                    ];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();

                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        (string) $response->getBody()
                    );
                }
            )
        ;
    }

    /**
     * Create request for operation 'patchListingsItem'.
     *
     * @param string                   $seller_id
     *                                                  A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param string                   $sku
     *                                                  A selling partner provided identifier for an Amazon listing. (required)
     * @param string[]                 $marketplace_ids
     *                                                  A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param ListingsItemPatchRequest $body
     *                                                  The request body schema for the &#x60;patchListingsItem&#x60; operation. (required)
     * @param null|string[]            $included_data
     *                                                  A comma-delimited list of data sets to include in the response. Default: &#x60;issues&#x60;. (optional)
     * @param null|string              $mode
     *                                                  The mode of operation for the request. (optional)
     * @param null|string              $issue_locale
     *                                                  A locale for localization of issues. When not provided, the default language code of the first marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function patchListingsItemRequest(
        string $seller_id,
        string $sku,
        array $marketplace_ids,
        ListingsItemPatchRequest $body,
        ?array $included_data = null,
        ?string $mode = null,
        ?string $issue_locale = null
    ): Request {
        // verify the required parameter 'seller_id' is set
        if (null === $seller_id || (is_array($seller_id) && 0 === count($seller_id))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $seller_id when calling patchListingsItem'
            );
        }
        // verify the required parameter 'sku' is set
        if (null === $sku || (is_array($sku) && 0 === count($sku))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $sku when calling patchListingsItem'
            );
        }
        // verify the required parameter 'marketplace_ids' is set
        if (null === $marketplace_ids || (is_array($marketplace_ids) && 0 === count($marketplace_ids))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $marketplace_ids when calling patchListingsItem'
            );
        }
        if (count($marketplace_ids) > 1) {
            throw new \InvalidArgumentException('invalid value for "$marketplace_ids" when calling ListingsApi.patchListingsItem, number of items must be less than or equal to 1.');
        }

        // verify the required parameter 'body' is set
        if (null === $body || (is_array($body) && 0 === count($body))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $body when calling patchListingsItem'
            );
        }

        $resourcePath = '/listings/2021-08-01/items/{sellerId}/{sku}';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $marketplace_ids,
            'marketplaceIds', // param base name
            'array', // openApiType
            'form', // style
            false, // explode
            true, // required
            $this->config
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $included_data,
            'includedData', // param base name
            'array', // openApiType
            'form', // style
            false, // explode
            false, // required
            $this->config
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $mode,
            'mode', // param base name
            'string', // openApiType
            '', // style
            false, // explode
            false, // required
            $this->config
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $issue_locale,
            'issueLocale', // param base name
            'string', // openApiType
            '', // style
            false, // explode
            false, // required
            $this->config
        ) ?? []);

        // path params
        if (null !== $seller_id) {
            $resourcePath = str_replace(
                '{sellerId}',
                ObjectSerializer::toPathValue($seller_id),
                $resourcePath
            );
        }
        // path params
        if (null !== $sku) {
            $resourcePath = str_replace(
                '{sku}',
                ObjectSerializer::toPathValue($sku),
                $resourcePath
            );
        }

        $headers = $this->headerSelector->selectHeaders(
            ['application/json'],
            'application/json',
            $multipart
        );

        // for model (json/xml)
        if (isset($body)) {
            if ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($body));
            } else {
                $httpBody = $body;
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
                    foreach ($formParamValueItems as $formParamValueItem) {
                        $multipartContents[] = [
                            'name' => $formParamName,
                            'contents' => $formParamValueItem,
                        ];
                    }
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);
            } elseif ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode($formParams);
            } else {
                // for HTTP post (form)
                $httpBody = ObjectSerializer::buildQuery($formParams, $this->config);
            }
        }

        $defaultHeaders = [];
        if ($this->config->getUserAgent()) {
            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
        }

        $headers = array_merge(
            $defaultHeaders,
            $headerParams,
            $headers
        );

        $query = ObjectSerializer::buildQuery($queryParams, $this->config);

        return new Request(
            'PATCH',
            $this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation putListingsItem.
     *
     * @param string                 $seller_id
     *                                                    A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param string                 $sku
     *                                                    A selling partner provided identifier for an Amazon listing. (required)
     * @param string[]               $marketplace_ids
     *                                                    A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param ListingsItemPutRequest $body
     *                                                    The request body schema for the &#x60;putListingsItem&#x60; operation. (required)
     * @param null|string[]          $included_data
     *                                                    A comma-delimited list of data sets to include in the response. Default: &#x60;issues&#x60;. (optional)
     * @param null|string            $mode
     *                                                    The mode of operation for the request. (optional)
     * @param null|string            $issue_locale
     *                                                    A locale for localization of issues. When not provided, the default language code of the first marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     * @param null|string            $restrictedDataToken Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function putListingsItem(
        string $seller_id,
        string $sku,
        array $marketplace_ids,
        ListingsItemPutRequest $body,
        ?array $included_data = null,
        ?string $mode = null,
        ?string $issue_locale = null,
        ?string $restrictedDataToken = null
    ): ListingsItemSubmissionResponse {
        list($response) = $this->putListingsItemWithHttpInfo($seller_id, $sku, $marketplace_ids, $body, $included_data, $mode, $issue_locale, $restrictedDataToken);

        return $response;
    }

    /**
     * Operation putListingsItemWithHttpInfo.
     *
     * @param string                 $seller_id
     *                                                    A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param string                 $sku
     *                                                    A selling partner provided identifier for an Amazon listing. (required)
     * @param string[]               $marketplace_ids
     *                                                    A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param ListingsItemPutRequest $body
     *                                                    The request body schema for the &#x60;putListingsItem&#x60; operation. (required)
     * @param null|string[]          $included_data
     *                                                    A comma-delimited list of data sets to include in the response. Default: &#x60;issues&#x60;. (optional)
     * @param null|string            $mode
     *                                                    The mode of operation for the request. (optional)
     * @param null|string            $issue_locale
     *                                                    A locale for localization of issues. When not provided, the default language code of the first marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     * @param null|string            $restrictedDataToken Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @return array of \SpApi\Model\listings\items\v2021_08_01\ListingsItemSubmissionResponse, HTTP status code, HTTP response headers (array of strings)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function putListingsItemWithHttpInfo(
        string $seller_id,
        string $sku,
        array $marketplace_ids,
        ListingsItemPutRequest $body,
        ?array $included_data = null,
        ?string $mode = null,
        ?string $issue_locale = null,
        ?string $restrictedDataToken = null
    ): array {
        $request = $this->putListingsItemRequest($seller_id, $sku, $marketplace_ids, $body, $included_data, $mode, $issue_locale);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ListingsApi-putListingsItem');
        } else {
            $request = $this->config->sign($request);
        }

        try {
            $options = $this->createHttpClientOption();

            try {
                if ($this->rateLimiterEnabled) {
                    $this->putListingsItemRateLimiter->consume()->ensureAccepted();
                }
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getResponse()->getBody()}",
                    (int) $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? (string) $e->getResponse()->getBody() : null
                );
            } catch (ConnectException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    (int) $e->getCode(),
                    null,
                    null
                );
            }

            $statusCode = $response->getStatusCode();

            if ($statusCode < 200 || $statusCode > 299) {
                throw new ApiException(
                    sprintf(
                        '[%d] Error connecting to the API (%s)',
                        $statusCode,
                        (string) $request->getUri()
                    ),
                    $statusCode,
                    $response->getHeaders(),
                    (string) $response->getBody()
                );
            }
            if ('\SpApi\Model\listings\items\v2021_08_01\ListingsItemSubmissionResponse' === '\SplFileObject') {
                $content = $response->getBody(); // stream goes to serializer
            } else {
                $content = (string) $response->getBody();
                if ('\SpApi\Model\listings\items\v2021_08_01\ListingsItemSubmissionResponse' !== 'string') {
                    $content = json_decode($content);
                }
            }

            return [
                ObjectSerializer::deserialize($content, '\SpApi\Model\listings\items\v2021_08_01\ListingsItemSubmissionResponse', []),
                $response->getStatusCode(),
                $response->getHeaders(),
            ];
        } catch (ApiException $e) {
            $data = ObjectSerializer::deserialize(
                $e->getResponseBody(),
                '\SpApi\Model\listings\items\v2021_08_01\ErrorList',
                $e->getResponseHeaders()
            );
            $e->setResponseObject($data);

            throw $e;
        }
    }

    /**
     * Operation putListingsItemAsync.
     *
     * @param string                 $seller_id
     *                                                A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param string                 $sku
     *                                                A selling partner provided identifier for an Amazon listing. (required)
     * @param string[]               $marketplace_ids
     *                                                A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param ListingsItemPutRequest $body
     *                                                The request body schema for the &#x60;putListingsItem&#x60; operation. (required)
     * @param null|string[]          $included_data
     *                                                A comma-delimited list of data sets to include in the response. Default: &#x60;issues&#x60;. (optional)
     * @param null|string            $mode
     *                                                The mode of operation for the request. (optional)
     * @param null|string            $issue_locale
     *                                                A locale for localization of issues. When not provided, the default language code of the first marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function putListingsItemAsync(
        string $seller_id,
        string $sku,
        array $marketplace_ids,
        ListingsItemPutRequest $body,
        ?array $included_data = null,
        ?string $mode = null,
        ?string $issue_locale = null
    ): PromiseInterface {
        return $this->putListingsItemAsyncWithHttpInfo($seller_id, $sku, $marketplace_ids, $body, $included_data, $mode, $issue_locale)
            ->then(
                function ($response) {
                    return $response[0];
                }
            )
        ;
    }

    /**
     * Operation putListingsItemAsyncWithHttpInfo.
     *
     * @param string                 $seller_id
     *                                                A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param string                 $sku
     *                                                A selling partner provided identifier for an Amazon listing. (required)
     * @param string[]               $marketplace_ids
     *                                                A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param ListingsItemPutRequest $body
     *                                                The request body schema for the &#x60;putListingsItem&#x60; operation. (required)
     * @param null|string[]          $included_data
     *                                                A comma-delimited list of data sets to include in the response. Default: &#x60;issues&#x60;. (optional)
     * @param null|string            $mode
     *                                                The mode of operation for the request. (optional)
     * @param null|string            $issue_locale
     *                                                A locale for localization of issues. When not provided, the default language code of the first marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function putListingsItemAsyncWithHttpInfo(
        string $seller_id,
        string $sku,
        array $marketplace_ids,
        ListingsItemPutRequest $body,
        ?array $included_data = null,
        ?string $mode = null,
        ?string $issue_locale = null,
        ?string $restrictedDataToken = null
    ): PromiseInterface {
        $returnType = '\SpApi\Model\listings\items\v2021_08_01\ListingsItemSubmissionResponse';
        $request = $this->putListingsItemRequest($seller_id, $sku, $marketplace_ids, $body, $included_data, $mode, $issue_locale);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ListingsApi-putListingsItem');
        } else {
            $request = $this->config->sign($request);
        }
        if ($this->rateLimiterEnabled) {
            $this->putListingsItemRateLimiter->consume()->ensureAccepted();
        }

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    if ('\SplFileObject' === $returnType) {
                        $content = $response->getBody(); // stream goes to serializer
                    } else {
                        $content = (string) $response->getBody();
                        if ('string' !== $returnType) {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializer::deserialize($content, $returnType, []),
                        $response->getStatusCode(),
                        $response->getHeaders(),
                    ];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();

                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        (string) $response->getBody()
                    );
                }
            )
        ;
    }

    /**
     * Create request for operation 'putListingsItem'.
     *
     * @param string                 $seller_id
     *                                                A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param string                 $sku
     *                                                A selling partner provided identifier for an Amazon listing. (required)
     * @param string[]               $marketplace_ids
     *                                                A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param ListingsItemPutRequest $body
     *                                                The request body schema for the &#x60;putListingsItem&#x60; operation. (required)
     * @param null|string[]          $included_data
     *                                                A comma-delimited list of data sets to include in the response. Default: &#x60;issues&#x60;. (optional)
     * @param null|string            $mode
     *                                                The mode of operation for the request. (optional)
     * @param null|string            $issue_locale
     *                                                A locale for localization of issues. When not provided, the default language code of the first marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function putListingsItemRequest(
        string $seller_id,
        string $sku,
        array $marketplace_ids,
        ListingsItemPutRequest $body,
        ?array $included_data = null,
        ?string $mode = null,
        ?string $issue_locale = null
    ): Request {
        // verify the required parameter 'seller_id' is set
        if (null === $seller_id || (is_array($seller_id) && 0 === count($seller_id))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $seller_id when calling putListingsItem'
            );
        }
        // verify the required parameter 'sku' is set
        if (null === $sku || (is_array($sku) && 0 === count($sku))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $sku when calling putListingsItem'
            );
        }
        // verify the required parameter 'marketplace_ids' is set
        if (null === $marketplace_ids || (is_array($marketplace_ids) && 0 === count($marketplace_ids))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $marketplace_ids when calling putListingsItem'
            );
        }
        if (count($marketplace_ids) > 1) {
            throw new \InvalidArgumentException('invalid value for "$marketplace_ids" when calling ListingsApi.putListingsItem, number of items must be less than or equal to 1.');
        }

        // verify the required parameter 'body' is set
        if (null === $body || (is_array($body) && 0 === count($body))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $body when calling putListingsItem'
            );
        }

        $resourcePath = '/listings/2021-08-01/items/{sellerId}/{sku}';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $marketplace_ids,
            'marketplaceIds', // param base name
            'array', // openApiType
            'form', // style
            false, // explode
            true, // required
            $this->config
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $included_data,
            'includedData', // param base name
            'array', // openApiType
            'form', // style
            false, // explode
            false, // required
            $this->config
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $mode,
            'mode', // param base name
            'string', // openApiType
            '', // style
            false, // explode
            false, // required
            $this->config
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $issue_locale,
            'issueLocale', // param base name
            'string', // openApiType
            '', // style
            false, // explode
            false, // required
            $this->config
        ) ?? []);

        // path params
        if (null !== $seller_id) {
            $resourcePath = str_replace(
                '{sellerId}',
                ObjectSerializer::toPathValue($seller_id),
                $resourcePath
            );
        }
        // path params
        if (null !== $sku) {
            $resourcePath = str_replace(
                '{sku}',
                ObjectSerializer::toPathValue($sku),
                $resourcePath
            );
        }

        $headers = $this->headerSelector->selectHeaders(
            ['application/json'],
            'application/json',
            $multipart
        );

        // for model (json/xml)
        if (isset($body)) {
            if ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($body));
            } else {
                $httpBody = $body;
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
                    foreach ($formParamValueItems as $formParamValueItem) {
                        $multipartContents[] = [
                            'name' => $formParamName,
                            'contents' => $formParamValueItem,
                        ];
                    }
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);
            } elseif ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode($formParams);
            } else {
                // for HTTP post (form)
                $httpBody = ObjectSerializer::buildQuery($formParams, $this->config);
            }
        }

        $defaultHeaders = [];
        if ($this->config->getUserAgent()) {
            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
        }

        $headers = array_merge(
            $defaultHeaders,
            $headerParams,
            $headers
        );

        $query = ObjectSerializer::buildQuery($queryParams, $this->config);

        return new Request(
            'PUT',
            $this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation searchListingsItems.
     *
     * @param string         $seller_id
     *                                              A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param string[]       $marketplace_ids
     *                                              A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param null|string    $issue_locale
     *                                              A locale that is used to localize issues. When not provided, the default language code of the first marketplace is used. Examples: \&quot;en_US\&quot;, \&quot;fr_CA\&quot;, \&quot;fr_FR\&quot;. When a localization is not available in the specified locale, localized messages default to \&quot;en_US\&quot;. (optional)
     * @param null|string[]  $included_data
     *                                              A comma-delimited list of datasets that you want to include in the response. Default: &#x60;summaries&#x60;. (optional)
     * @param null|string[]  $identifiers
     *                                              A comma-delimited list of product identifiers that you can use to search for listings items.   **Note**:  1. This is required when you specify &#x60;identifiersType&#x60;. 2. You cannot use &#39;identifiers&#39; if you specify &#x60;variationParentSku&#x60; or &#x60;packageHierarchySku&#x60;. (optional)
     * @param null|string    $identifiers_type
     *                                              A type of product identifiers that you can use to search for listings items.   **Note**:  This is required when &#x60;identifiers&#x60; is provided. (optional)
     * @param null|string    $variation_parent_sku
     *                                              Filters results to include listing items that are variation children of the specified SKU.   **Note**: You cannot use &#x60;variationParentSku&#x60; if you include &#x60;identifiers&#x60; or &#x60;packageHierarchySku&#x60; in your request. (optional)
     * @param null|string    $package_hierarchy_sku
     *                                              Filter results to include listing items that contain or are contained by the specified SKU.   **Note**: You cannot use &#x60;packageHierarchySku&#x60; if you include &#x60;identifiers&#x60; or &#x60;variationParentSku&#x60; in your request. (optional)
     * @param null|\DateTime $created_after
     *                                              A date-time that is used to filter listing items. The response includes listings items that were created at or after this time. Values are in [ISO 8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param null|\DateTime $created_before
     *                                              A date-time that is used to filter listing items. The response includes listings items that were created at or before this time. Values are in [ISO 8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param null|\DateTime $last_updated_after
     *                                              A date-time that is used to filter listing items. The response includes listings items that were last updated at or after this time. Values are in [ISO 8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param null|\DateTime $last_updated_before
     *                                              A date-time that is used to filter listing items. The response includes listings items that were last updated at or before this time. Values are in [ISO 8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param null|string[]  $with_issue_severity
     *                                              Filter results to include only listing items that have issues that match one or more of the specified severity levels. (optional)
     * @param null|string[]  $with_status
     *                                              Filter results to include only listing items that have the specified status. (optional)
     * @param null|string[]  $without_status
     *                                              Filter results to include only listing items that don&#39;t contain the specified statuses. (optional)
     * @param null|string    $sort_by
     *                                              An attribute by which to sort the returned listing items. (optional, default to 'lastUpdatedDate')
     * @param null|string    $sort_order
     *                                              The order in which to sort the result items. (optional, default to 'DESC')
     * @param null|int       $page_size
     *                                              The number of results that you want to include on each page. (optional, default to 10)
     * @param null|string    $page_token
     *                                              A token that you can use to fetch a specific page when there are multiple pages of results. (optional)
     * @param null|string    $restrictedDataToken   Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function searchListingsItems(
        string $seller_id,
        array $marketplace_ids,
        ?string $issue_locale = null,
        ?array $included_data = null,
        ?array $identifiers = null,
        ?string $identifiers_type = null,
        ?string $variation_parent_sku = null,
        ?string $package_hierarchy_sku = null,
        ?\DateTime $created_after = null,
        ?\DateTime $created_before = null,
        ?\DateTime $last_updated_after = null,
        ?\DateTime $last_updated_before = null,
        ?array $with_issue_severity = null,
        ?array $with_status = null,
        ?array $without_status = null,
        ?string $sort_by = 'lastUpdatedDate',
        ?string $sort_order = 'DESC',
        ?int $page_size = 10,
        ?string $page_token = null,
        ?string $restrictedDataToken = null
    ): ItemSearchResults {
        list($response) = $this->searchListingsItemsWithHttpInfo($seller_id, $marketplace_ids, $issue_locale, $included_data, $identifiers, $identifiers_type, $variation_parent_sku, $package_hierarchy_sku, $created_after, $created_before, $last_updated_after, $last_updated_before, $with_issue_severity, $with_status, $without_status, $sort_by, $sort_order, $page_size, $page_token, $restrictedDataToken);

        return $response;
    }

    /**
     * Operation searchListingsItemsWithHttpInfo.
     *
     * @param string         $seller_id
     *                                              A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param string[]       $marketplace_ids
     *                                              A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param null|string    $issue_locale
     *                                              A locale that is used to localize issues. When not provided, the default language code of the first marketplace is used. Examples: \&quot;en_US\&quot;, \&quot;fr_CA\&quot;, \&quot;fr_FR\&quot;. When a localization is not available in the specified locale, localized messages default to \&quot;en_US\&quot;. (optional)
     * @param null|string[]  $included_data
     *                                              A comma-delimited list of datasets that you want to include in the response. Default: &#x60;summaries&#x60;. (optional)
     * @param null|string[]  $identifiers
     *                                              A comma-delimited list of product identifiers that you can use to search for listings items.   **Note**:  1. This is required when you specify &#x60;identifiersType&#x60;. 2. You cannot use &#39;identifiers&#39; if you specify &#x60;variationParentSku&#x60; or &#x60;packageHierarchySku&#x60;. (optional)
     * @param null|string    $identifiers_type
     *                                              A type of product identifiers that you can use to search for listings items.   **Note**:  This is required when &#x60;identifiers&#x60; is provided. (optional)
     * @param null|string    $variation_parent_sku
     *                                              Filters results to include listing items that are variation children of the specified SKU.   **Note**: You cannot use &#x60;variationParentSku&#x60; if you include &#x60;identifiers&#x60; or &#x60;packageHierarchySku&#x60; in your request. (optional)
     * @param null|string    $package_hierarchy_sku
     *                                              Filter results to include listing items that contain or are contained by the specified SKU.   **Note**: You cannot use &#x60;packageHierarchySku&#x60; if you include &#x60;identifiers&#x60; or &#x60;variationParentSku&#x60; in your request. (optional)
     * @param null|\DateTime $created_after
     *                                              A date-time that is used to filter listing items. The response includes listings items that were created at or after this time. Values are in [ISO 8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param null|\DateTime $created_before
     *                                              A date-time that is used to filter listing items. The response includes listings items that were created at or before this time. Values are in [ISO 8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param null|\DateTime $last_updated_after
     *                                              A date-time that is used to filter listing items. The response includes listings items that were last updated at or after this time. Values are in [ISO 8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param null|\DateTime $last_updated_before
     *                                              A date-time that is used to filter listing items. The response includes listings items that were last updated at or before this time. Values are in [ISO 8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param null|string[]  $with_issue_severity
     *                                              Filter results to include only listing items that have issues that match one or more of the specified severity levels. (optional)
     * @param null|string[]  $with_status
     *                                              Filter results to include only listing items that have the specified status. (optional)
     * @param null|string[]  $without_status
     *                                              Filter results to include only listing items that don&#39;t contain the specified statuses. (optional)
     * @param null|string    $sort_by
     *                                              An attribute by which to sort the returned listing items. (optional, default to 'lastUpdatedDate')
     * @param null|string    $sort_order
     *                                              The order in which to sort the result items. (optional, default to 'DESC')
     * @param null|int       $page_size
     *                                              The number of results that you want to include on each page. (optional, default to 10)
     * @param null|string    $page_token
     *                                              A token that you can use to fetch a specific page when there are multiple pages of results. (optional)
     * @param null|string    $restrictedDataToken   Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @return array of \SpApi\Model\listings\items\v2021_08_01\ItemSearchResults, HTTP status code, HTTP response headers (array of strings)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function searchListingsItemsWithHttpInfo(
        string $seller_id,
        array $marketplace_ids,
        ?string $issue_locale = null,
        ?array $included_data = null,
        ?array $identifiers = null,
        ?string $identifiers_type = null,
        ?string $variation_parent_sku = null,
        ?string $package_hierarchy_sku = null,
        ?\DateTime $created_after = null,
        ?\DateTime $created_before = null,
        ?\DateTime $last_updated_after = null,
        ?\DateTime $last_updated_before = null,
        ?array $with_issue_severity = null,
        ?array $with_status = null,
        ?array $without_status = null,
        ?string $sort_by = 'lastUpdatedDate',
        ?string $sort_order = 'DESC',
        ?int $page_size = 10,
        ?string $page_token = null,
        ?string $restrictedDataToken = null
    ): array {
        $request = $this->searchListingsItemsRequest($seller_id, $marketplace_ids, $issue_locale, $included_data, $identifiers, $identifiers_type, $variation_parent_sku, $package_hierarchy_sku, $created_after, $created_before, $last_updated_after, $last_updated_before, $with_issue_severity, $with_status, $without_status, $sort_by, $sort_order, $page_size, $page_token);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ListingsApi-searchListingsItems');
        } else {
            $request = $this->config->sign($request);
        }

        try {
            $options = $this->createHttpClientOption();

            try {
                if ($this->rateLimiterEnabled) {
                    $this->searchListingsItemsRateLimiter->consume()->ensureAccepted();
                }
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getResponse()->getBody()}",
                    (int) $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? (string) $e->getResponse()->getBody() : null
                );
            } catch (ConnectException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    (int) $e->getCode(),
                    null,
                    null
                );
            }

            $statusCode = $response->getStatusCode();

            if ($statusCode < 200 || $statusCode > 299) {
                throw new ApiException(
                    sprintf(
                        '[%d] Error connecting to the API (%s)',
                        $statusCode,
                        (string) $request->getUri()
                    ),
                    $statusCode,
                    $response->getHeaders(),
                    (string) $response->getBody()
                );
            }
            if ('\SpApi\Model\listings\items\v2021_08_01\ItemSearchResults' === '\SplFileObject') {
                $content = $response->getBody(); // stream goes to serializer
            } else {
                $content = (string) $response->getBody();
                if ('\SpApi\Model\listings\items\v2021_08_01\ItemSearchResults' !== 'string') {
                    $content = json_decode($content);
                }
            }

            return [
                ObjectSerializer::deserialize($content, '\SpApi\Model\listings\items\v2021_08_01\ItemSearchResults', []),
                $response->getStatusCode(),
                $response->getHeaders(),
            ];
        } catch (ApiException $e) {
            $data = ObjectSerializer::deserialize(
                $e->getResponseBody(),
                '\SpApi\Model\listings\items\v2021_08_01\ErrorList',
                $e->getResponseHeaders()
            );
            $e->setResponseObject($data);

            throw $e;
        }
    }

    /**
     * Operation searchListingsItemsAsync.
     *
     * @param string         $seller_id
     *                                              A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param string[]       $marketplace_ids
     *                                              A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param null|string    $issue_locale
     *                                              A locale that is used to localize issues. When not provided, the default language code of the first marketplace is used. Examples: \&quot;en_US\&quot;, \&quot;fr_CA\&quot;, \&quot;fr_FR\&quot;. When a localization is not available in the specified locale, localized messages default to \&quot;en_US\&quot;. (optional)
     * @param null|string[]  $included_data
     *                                              A comma-delimited list of datasets that you want to include in the response. Default: &#x60;summaries&#x60;. (optional)
     * @param null|string[]  $identifiers
     *                                              A comma-delimited list of product identifiers that you can use to search for listings items.   **Note**:  1. This is required when you specify &#x60;identifiersType&#x60;. 2. You cannot use &#39;identifiers&#39; if you specify &#x60;variationParentSku&#x60; or &#x60;packageHierarchySku&#x60;. (optional)
     * @param null|string    $identifiers_type
     *                                              A type of product identifiers that you can use to search for listings items.   **Note**:  This is required when &#x60;identifiers&#x60; is provided. (optional)
     * @param null|string    $variation_parent_sku
     *                                              Filters results to include listing items that are variation children of the specified SKU.   **Note**: You cannot use &#x60;variationParentSku&#x60; if you include &#x60;identifiers&#x60; or &#x60;packageHierarchySku&#x60; in your request. (optional)
     * @param null|string    $package_hierarchy_sku
     *                                              Filter results to include listing items that contain or are contained by the specified SKU.   **Note**: You cannot use &#x60;packageHierarchySku&#x60; if you include &#x60;identifiers&#x60; or &#x60;variationParentSku&#x60; in your request. (optional)
     * @param null|\DateTime $created_after
     *                                              A date-time that is used to filter listing items. The response includes listings items that were created at or after this time. Values are in [ISO 8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param null|\DateTime $created_before
     *                                              A date-time that is used to filter listing items. The response includes listings items that were created at or before this time. Values are in [ISO 8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param null|\DateTime $last_updated_after
     *                                              A date-time that is used to filter listing items. The response includes listings items that were last updated at or after this time. Values are in [ISO 8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param null|\DateTime $last_updated_before
     *                                              A date-time that is used to filter listing items. The response includes listings items that were last updated at or before this time. Values are in [ISO 8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param null|string[]  $with_issue_severity
     *                                              Filter results to include only listing items that have issues that match one or more of the specified severity levels. (optional)
     * @param null|string[]  $with_status
     *                                              Filter results to include only listing items that have the specified status. (optional)
     * @param null|string[]  $without_status
     *                                              Filter results to include only listing items that don&#39;t contain the specified statuses. (optional)
     * @param null|string    $sort_by
     *                                              An attribute by which to sort the returned listing items. (optional, default to 'lastUpdatedDate')
     * @param null|string    $sort_order
     *                                              The order in which to sort the result items. (optional, default to 'DESC')
     * @param null|int       $page_size
     *                                              The number of results that you want to include on each page. (optional, default to 10)
     * @param null|string    $page_token
     *                                              A token that you can use to fetch a specific page when there are multiple pages of results. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function searchListingsItemsAsync(
        string $seller_id,
        array $marketplace_ids,
        ?string $issue_locale = null,
        ?array $included_data = null,
        ?array $identifiers = null,
        ?string $identifiers_type = null,
        ?string $variation_parent_sku = null,
        ?string $package_hierarchy_sku = null,
        ?\DateTime $created_after = null,
        ?\DateTime $created_before = null,
        ?\DateTime $last_updated_after = null,
        ?\DateTime $last_updated_before = null,
        ?array $with_issue_severity = null,
        ?array $with_status = null,
        ?array $without_status = null,
        ?string $sort_by = 'lastUpdatedDate',
        ?string $sort_order = 'DESC',
        ?int $page_size = 10,
        ?string $page_token = null
    ): PromiseInterface {
        return $this->searchListingsItemsAsyncWithHttpInfo($seller_id, $marketplace_ids, $issue_locale, $included_data, $identifiers, $identifiers_type, $variation_parent_sku, $package_hierarchy_sku, $created_after, $created_before, $last_updated_after, $last_updated_before, $with_issue_severity, $with_status, $without_status, $sort_by, $sort_order, $page_size, $page_token)
            ->then(
                function ($response) {
                    return $response[0];
                }
            )
        ;
    }

    /**
     * Operation searchListingsItemsAsyncWithHttpInfo.
     *
     * @param string         $seller_id
     *                                              A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param string[]       $marketplace_ids
     *                                              A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param null|string    $issue_locale
     *                                              A locale that is used to localize issues. When not provided, the default language code of the first marketplace is used. Examples: \&quot;en_US\&quot;, \&quot;fr_CA\&quot;, \&quot;fr_FR\&quot;. When a localization is not available in the specified locale, localized messages default to \&quot;en_US\&quot;. (optional)
     * @param null|string[]  $included_data
     *                                              A comma-delimited list of datasets that you want to include in the response. Default: &#x60;summaries&#x60;. (optional)
     * @param null|string[]  $identifiers
     *                                              A comma-delimited list of product identifiers that you can use to search for listings items.   **Note**:  1. This is required when you specify &#x60;identifiersType&#x60;. 2. You cannot use &#39;identifiers&#39; if you specify &#x60;variationParentSku&#x60; or &#x60;packageHierarchySku&#x60;. (optional)
     * @param null|string    $identifiers_type
     *                                              A type of product identifiers that you can use to search for listings items.   **Note**:  This is required when &#x60;identifiers&#x60; is provided. (optional)
     * @param null|string    $variation_parent_sku
     *                                              Filters results to include listing items that are variation children of the specified SKU.   **Note**: You cannot use &#x60;variationParentSku&#x60; if you include &#x60;identifiers&#x60; or &#x60;packageHierarchySku&#x60; in your request. (optional)
     * @param null|string    $package_hierarchy_sku
     *                                              Filter results to include listing items that contain or are contained by the specified SKU.   **Note**: You cannot use &#x60;packageHierarchySku&#x60; if you include &#x60;identifiers&#x60; or &#x60;variationParentSku&#x60; in your request. (optional)
     * @param null|\DateTime $created_after
     *                                              A date-time that is used to filter listing items. The response includes listings items that were created at or after this time. Values are in [ISO 8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param null|\DateTime $created_before
     *                                              A date-time that is used to filter listing items. The response includes listings items that were created at or before this time. Values are in [ISO 8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param null|\DateTime $last_updated_after
     *                                              A date-time that is used to filter listing items. The response includes listings items that were last updated at or after this time. Values are in [ISO 8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param null|\DateTime $last_updated_before
     *                                              A date-time that is used to filter listing items. The response includes listings items that were last updated at or before this time. Values are in [ISO 8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param null|string[]  $with_issue_severity
     *                                              Filter results to include only listing items that have issues that match one or more of the specified severity levels. (optional)
     * @param null|string[]  $with_status
     *                                              Filter results to include only listing items that have the specified status. (optional)
     * @param null|string[]  $without_status
     *                                              Filter results to include only listing items that don&#39;t contain the specified statuses. (optional)
     * @param null|string    $sort_by
     *                                              An attribute by which to sort the returned listing items. (optional, default to 'lastUpdatedDate')
     * @param null|string    $sort_order
     *                                              The order in which to sort the result items. (optional, default to 'DESC')
     * @param null|int       $page_size
     *                                              The number of results that you want to include on each page. (optional, default to 10)
     * @param null|string    $page_token
     *                                              A token that you can use to fetch a specific page when there are multiple pages of results. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function searchListingsItemsAsyncWithHttpInfo(
        string $seller_id,
        array $marketplace_ids,
        ?string $issue_locale = null,
        ?array $included_data = null,
        ?array $identifiers = null,
        ?string $identifiers_type = null,
        ?string $variation_parent_sku = null,
        ?string $package_hierarchy_sku = null,
        ?\DateTime $created_after = null,
        ?\DateTime $created_before = null,
        ?\DateTime $last_updated_after = null,
        ?\DateTime $last_updated_before = null,
        ?array $with_issue_severity = null,
        ?array $with_status = null,
        ?array $without_status = null,
        ?string $sort_by = 'lastUpdatedDate',
        ?string $sort_order = 'DESC',
        ?int $page_size = 10,
        ?string $page_token = null,
        ?string $restrictedDataToken = null
    ): PromiseInterface {
        $returnType = '\SpApi\Model\listings\items\v2021_08_01\ItemSearchResults';
        $request = $this->searchListingsItemsRequest($seller_id, $marketplace_ids, $issue_locale, $included_data, $identifiers, $identifiers_type, $variation_parent_sku, $package_hierarchy_sku, $created_after, $created_before, $last_updated_after, $last_updated_before, $with_issue_severity, $with_status, $without_status, $sort_by, $sort_order, $page_size, $page_token);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ListingsApi-searchListingsItems');
        } else {
            $request = $this->config->sign($request);
        }
        if ($this->rateLimiterEnabled) {
            $this->searchListingsItemsRateLimiter->consume()->ensureAccepted();
        }

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    if ('\SplFileObject' === $returnType) {
                        $content = $response->getBody(); // stream goes to serializer
                    } else {
                        $content = (string) $response->getBody();
                        if ('string' !== $returnType) {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializer::deserialize($content, $returnType, []),
                        $response->getStatusCode(),
                        $response->getHeaders(),
                    ];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();

                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        (string) $response->getBody()
                    );
                }
            )
        ;
    }

    /**
     * Create request for operation 'searchListingsItems'.
     *
     * @param string         $seller_id
     *                                              A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param string[]       $marketplace_ids
     *                                              A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param null|string    $issue_locale
     *                                              A locale that is used to localize issues. When not provided, the default language code of the first marketplace is used. Examples: \&quot;en_US\&quot;, \&quot;fr_CA\&quot;, \&quot;fr_FR\&quot;. When a localization is not available in the specified locale, localized messages default to \&quot;en_US\&quot;. (optional)
     * @param null|string[]  $included_data
     *                                              A comma-delimited list of datasets that you want to include in the response. Default: &#x60;summaries&#x60;. (optional)
     * @param null|string[]  $identifiers
     *                                              A comma-delimited list of product identifiers that you can use to search for listings items.   **Note**:  1. This is required when you specify &#x60;identifiersType&#x60;. 2. You cannot use &#39;identifiers&#39; if you specify &#x60;variationParentSku&#x60; or &#x60;packageHierarchySku&#x60;. (optional)
     * @param null|string    $identifiers_type
     *                                              A type of product identifiers that you can use to search for listings items.   **Note**:  This is required when &#x60;identifiers&#x60; is provided. (optional)
     * @param null|string    $variation_parent_sku
     *                                              Filters results to include listing items that are variation children of the specified SKU.   **Note**: You cannot use &#x60;variationParentSku&#x60; if you include &#x60;identifiers&#x60; or &#x60;packageHierarchySku&#x60; in your request. (optional)
     * @param null|string    $package_hierarchy_sku
     *                                              Filter results to include listing items that contain or are contained by the specified SKU.   **Note**: You cannot use &#x60;packageHierarchySku&#x60; if you include &#x60;identifiers&#x60; or &#x60;variationParentSku&#x60; in your request. (optional)
     * @param null|\DateTime $created_after
     *                                              A date-time that is used to filter listing items. The response includes listings items that were created at or after this time. Values are in [ISO 8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param null|\DateTime $created_before
     *                                              A date-time that is used to filter listing items. The response includes listings items that were created at or before this time. Values are in [ISO 8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param null|\DateTime $last_updated_after
     *                                              A date-time that is used to filter listing items. The response includes listings items that were last updated at or after this time. Values are in [ISO 8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param null|\DateTime $last_updated_before
     *                                              A date-time that is used to filter listing items. The response includes listings items that were last updated at or before this time. Values are in [ISO 8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param null|string[]  $with_issue_severity
     *                                              Filter results to include only listing items that have issues that match one or more of the specified severity levels. (optional)
     * @param null|string[]  $with_status
     *                                              Filter results to include only listing items that have the specified status. (optional)
     * @param null|string[]  $without_status
     *                                              Filter results to include only listing items that don&#39;t contain the specified statuses. (optional)
     * @param null|string    $sort_by
     *                                              An attribute by which to sort the returned listing items. (optional, default to 'lastUpdatedDate')
     * @param null|string    $sort_order
     *                                              The order in which to sort the result items. (optional, default to 'DESC')
     * @param null|int       $page_size
     *                                              The number of results that you want to include on each page. (optional, default to 10)
     * @param null|string    $page_token
     *                                              A token that you can use to fetch a specific page when there are multiple pages of results. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function searchListingsItemsRequest(
        string $seller_id,
        array $marketplace_ids,
        ?string $issue_locale = null,
        ?array $included_data = null,
        ?array $identifiers = null,
        ?string $identifiers_type = null,
        ?string $variation_parent_sku = null,
        ?string $package_hierarchy_sku = null,
        ?\DateTime $created_after = null,
        ?\DateTime $created_before = null,
        ?\DateTime $last_updated_after = null,
        ?\DateTime $last_updated_before = null,
        ?array $with_issue_severity = null,
        ?array $with_status = null,
        ?array $without_status = null,
        ?string $sort_by = 'lastUpdatedDate',
        ?string $sort_order = 'DESC',
        ?int $page_size = 10,
        ?string $page_token = null
    ): Request {
        // verify the required parameter 'seller_id' is set
        if (null === $seller_id || (is_array($seller_id) && 0 === count($seller_id))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $seller_id when calling searchListingsItems'
            );
        }
        // verify the required parameter 'marketplace_ids' is set
        if (null === $marketplace_ids || (is_array($marketplace_ids) && 0 === count($marketplace_ids))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $marketplace_ids when calling searchListingsItems'
            );
        }
        if (count($marketplace_ids) > 1) {
            throw new \InvalidArgumentException('invalid value for "$marketplace_ids" when calling ListingsApi.searchListingsItems, number of items must be less than or equal to 1.');
        }

        if (null !== $identifiers && count($identifiers) > 20) {
            throw new \InvalidArgumentException('invalid value for "$identifiers" when calling ListingsApi.searchListingsItems, number of items must be less than or equal to 20.');
        }

        if (null !== $page_size && $page_size > 20) {
            throw new \InvalidArgumentException('invalid value for "$page_size" when calling ListingsApi.searchListingsItems, must be smaller than or equal to 20.');
        }

        $resourcePath = '/listings/2021-08-01/items/{sellerId}';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $marketplace_ids,
            'marketplaceIds', // param base name
            'array', // openApiType
            'form', // style
            false, // explode
            true, // required
            $this->config
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $issue_locale,
            'issueLocale', // param base name
            'string', // openApiType
            '', // style
            false, // explode
            false, // required
            $this->config
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $included_data,
            'includedData', // param base name
            'array', // openApiType
            'form', // style
            false, // explode
            false, // required
            $this->config
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $identifiers,
            'identifiers', // param base name
            'array', // openApiType
            'form', // style
            false, // explode
            false, // required
            $this->config
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $identifiers_type,
            'identifiersType', // param base name
            'string', // openApiType
            '', // style
            false, // explode
            false, // required
            $this->config
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $variation_parent_sku,
            'variationParentSku', // param base name
            'string', // openApiType
            '', // style
            false, // explode
            false, // required
            $this->config
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $package_hierarchy_sku,
            'packageHierarchySku', // param base name
            'string', // openApiType
            '', // style
            false, // explode
            false, // required
            $this->config
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $created_after,
            'createdAfter', // param base name
            'string', // openApiType
            '', // style
            false, // explode
            false, // required
            $this->config
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $created_before,
            'createdBefore', // param base name
            'string', // openApiType
            '', // style
            false, // explode
            false, // required
            $this->config
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $last_updated_after,
            'lastUpdatedAfter', // param base name
            'string', // openApiType
            '', // style
            false, // explode
            false, // required
            $this->config
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $last_updated_before,
            'lastUpdatedBefore', // param base name
            'string', // openApiType
            '', // style
            false, // explode
            false, // required
            $this->config
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $with_issue_severity,
            'withIssueSeverity', // param base name
            'array', // openApiType
            'form', // style
            false, // explode
            false, // required
            $this->config
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $with_status,
            'withStatus', // param base name
            'array', // openApiType
            'form', // style
            false, // explode
            false, // required
            $this->config
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $without_status,
            'withoutStatus', // param base name
            'array', // openApiType
            'form', // style
            false, // explode
            false, // required
            $this->config
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $sort_by,
            'sortBy', // param base name
            'string', // openApiType
            '', // style
            false, // explode
            false, // required
            $this->config
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $sort_order,
            'sortOrder', // param base name
            'string', // openApiType
            '', // style
            false, // explode
            false, // required
            $this->config
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $page_size,
            'pageSize', // param base name
            'integer', // openApiType
            '', // style
            false, // explode
            false, // required
            $this->config
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $page_token,
            'pageToken', // param base name
            'string', // openApiType
            '', // style
            false, // explode
            false, // required
            $this->config
        ) ?? []);

        // path params
        if (null !== $seller_id) {
            $resourcePath = str_replace(
                '{sellerId}',
                ObjectSerializer::toPathValue($seller_id),
                $resourcePath
            );
        }

        $headers = $this->headerSelector->selectHeaders(
            ['application/json'],
            '',
            $multipart
        );

        // for model (json/xml)
        if (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
                    foreach ($formParamValueItems as $formParamValueItem) {
                        $multipartContents[] = [
                            'name' => $formParamName,
                            'contents' => $formParamValueItem,
                        ];
                    }
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);
            } elseif ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode($formParams);
            } else {
                // for HTTP post (form)
                $httpBody = ObjectSerializer::buildQuery($formParams, $this->config);
            }
        }

        $defaultHeaders = [];
        if ($this->config->getUserAgent()) {
            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
        }

        $headers = array_merge(
            $defaultHeaders,
            $headerParams,
            $headers
        );

        $query = ObjectSerializer::buildQuery($queryParams, $this->config);

        return new Request(
            'GET',
            $this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Create http client option.
     *
     * @return array of http client options
     *
     * @throws \RuntimeException on file opening failure
     */
    protected function createHttpClientOption(): array
    {
        $options = [];
        if ($this->config->getDebug()) {
            $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a');
            if (!$options[RequestOptions::DEBUG]) {
                throw new \RuntimeException('Failed to open the debug file: '.$this->config->getDebugFile());
            }
        }

        return $options;
    }
}
